//
//  MyCollectTableViewCell.m
//  ZLExamination
//
//  Created by Lei_Zhong_Xun on 2017/8/21.
//  Copyright © 2017年 Zheng. All rights reserved.
//

#import "MyCollectTableViewCell.h"
#import "MyCollectModel.h"

@implementation MyCollectTableViewCell

- (void)setModel:(MyCollectModel *)model {
    _model = model;
    
    _numberLabel.text = _model.count;
    _titleLabel.text = _model.curriculum_name;

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.numberLabel];
        [self.contentView addSubview:self.exerciseButton];
    }
    return self;
}

#pragma mark - 布局
- (void)layoutSubviews
{
    [super layoutSubviews];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(15);
        make.right.equalTo(self.contentView.mas_right).offset(- 100);
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.height.equalTo(@16);
    }];
    [_exerciseButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(- 15);
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.height.equalTo(@25);
        make.width.equalTo(@25);
    }];
    [_numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_exerciseButton.mas_left).offset(- 20);
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.height.equalTo(@25);
        make.width.equalTo(@25);
    }];
    
}

#pragma mark - lazy load
- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = kCX_FONT(13);
        _titleLabel.textColor = kRGB_COLOR(51, 51, 51, 1.0);
    }
    return _titleLabel;
}
- (UILabel *)numberLabel
{
    if (!_numberLabel) {
        _numberLabel = [[UILabel alloc] init];
        _numberLabel.font = kCX_FONT(12);
        _numberLabel.textColor = kRGB_COLOR(36, 151, 240, 1.0);
    }
    return _numberLabel;
}
- (UIButton *)exerciseButton
{
    if (!_exerciseButton) {
        _exerciseButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_exerciseButton setImage:[UIImage imageNamed:@"编辑"] forState:UIControlStateNormal];
    }
    return _exerciseButton;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
